package by.demchenko.sample.webapp.page.home.panel;

import by.demchenko.sample.datamodel.Person;
import by.demchenko.sample.webapp.page.home.BaseLayout;
import by.demchenko.sample.webapp.page.home.cards.TeacherCard;
import by.demchenko.sample.webapp.page.home.teachers.TeacherCoursesPage;
import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.markup.html.image.Image;
import org.apache.wicket.markup.html.link.Link;
import org.apache.wicket.markup.html.panel.Panel;
import org.apache.wicket.model.Model;
import org.apache.wicket.request.resource.PackageResourceReference;


public class TeacherPanel extends Panel {

    public TeacherPanel(String id, Person teacher) {
        super(id, Model.of(teacher));
        add(new Image("teacherImage", new PackageResourceReference(BaseLayout.class, "/teachers/images/" + teacher.getId() + ".jpg")));

        Link link = new Link("teacherLink") {
            @Override
            public void onClick() {
                setResponsePage(new TeacherCard(teacher));
            }
        };
        add(link);

        link.add(new Label("teacherName", teacher.getFullName(getSession().getLocale())));
    }
}
